package com.aimee.keyboard;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;

public class KeyboardUtil {
    public static void hideSoftKeyboard(Activity activity, View clickView) {
        if (activity == null || clickView == null)
            return;
        InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);

        // 如果view是输入法的活动view，则返回true
//        if (inputMethodManager.isActive(activity.getCurrentFocus())) {
//            Toast.makeText(activity, "true", Toast.LENGTH_SHORT).show();
//            clickView.requestFocus();
            inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
//        } else {
//            Toast.makeText(activity, "false", Toast.LENGTH_SHORT).show();
//        }
    }
}
